<template>
	<view>
		<image class="bg1" src="../../images/bg1.png"></image>
		<view class="plr30 box_b">
			<view class="conBox bgfff p30 pos overHidden" style="top: -230rpx;">
				<view class="ipt mt30 flex_start flex_items">
					<image class="icon" src="../../images/phone.png"></image>
					<input class="ipt f30" v-model="username" placeholder="请输入账号" placeholder-class="c9" />
				</view>
				<view class="ipt mt30 flex_start flex_items mb20">
					<image class="icon" src="../../images/password.png"></image>
					<input class="ipt f30" v-model="password" password placeholder="请输入密码" placeholder-class="c9" />
				</view>
				<view class="flex_center flex_items ptb40 mb10">
					<view @click="submit" class="btn1 flex_center flex_items f32 bold cf">登录</view>
				</view>
			</view>

		</view>
	</view>
</template>
<script>
	let common = getApp().globalData.commonFun;
	let util = getApp().globalData.utilFun;
	export default {
		components: {},
		data() {
			return {
				imghttp: getApp().globalData.imghttp,
				username: '',
				password: "",
			}
		},
		async onLoad() {

		},
		methods: {
			async submit() {
				let val = {
					username: this.username,
					password: this.password,
				}
				if (this.username == "") {
					common.showTimeToast('请输入账号');
					return;
				}

				if (this.password == "") {
					common.showTimeToast('请输入密码');
					return;
				}
				let url = 'arts/login';
				common.showLoading("...");
				let res = await util.httpRequest(url, val, "POST");
				common.hideLoading();
				if (res.result == "fail") {
					common.showTimeToast(res.msg);
					return;
				}
				common.setStorage("token", res.results.token);
				let opUl = '/pages/enrollList/enrollList';
				if(common.getStorage('openurl')) {
					opUl = common.getStorage('openurl');
				}
				console.log(opUl)
				common.showTimeToast("登录成功");
				setTimeout((rs) => {
					uni.redirectTo({
						url: opUl
					})
				}, 2000)
			},
		},
	}
</script>


<style>
	page {
		background: #f8f8f8;
	}
</style>
<style scoped>
	Page {
		background: #f8f8f8;
	}

	.bg1 {
		width: 750rpx;
		height: 550rpx;
	}

	.ipt {
		width: 100%;
		height: 90rpx;
		border-radius: 45rpx;
		background: #f8f8f8;
	}

	.icon {
		width: 40rpx;
		height: 40rpx;
		margin: 0 20rpx;
	}

	.btn1 {
		width: 630rpx;
		height: 90rpx;
		border-radius: 45rpx;
		background: #15a183;
	}
</style>